from socket import *

def main():
    tcp_client_socket = socket(AF_INET, SOCK_STREAM)
    server_ip = '192.168.221.1'
    server_port = 2000
    tcp_client_socket.connect((server_ip, server_port))
    file_name = input("请输入要下载的文件名：")
    tcp_client_socket.send(file_name.encode("utf-8"))
    recv_data = tcp_client_socket.recv(1024)
    if recv_data:
        with open("[接收]" + file_name, "wb") as f:
            f.write(recv_data)

    tcp_client_socket.close()


if __name__ == "__main__":
    main()
